//
//  StatusForwordCell.swift
//  仿一个新浪微博
//
//  Created by 孙家林 on 15/9/23.
//  Copyright © 2015年 sunjialin. All rights reserved.
//

import UIKit

//转发微博
class StatusForwordCell: StatusCell {
    
    override var status: Status? {
        didSet {
            
            let name = status?.retweeted_status?.user?.name ?? ""
            
            let text = status?.retweeted_status?.text ?? ""
            
            forwordLabel.text = "@" + name + ":" + text
        }
    }
    
    override func setUpUI(){
        
        super.setUpUI()
        
        contentView.insertSubview(backButton, belowSubview: pictureView)
        
        contentView.insertSubview(forwordLabel, aboveSubview: backButton)
        
//        forwordLabel.text = "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"
        
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -statusCellControlMargin, y: statusCellControlMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        forwordLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: statusCellControlMargin, y: statusCellControlMargin))
        
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwordLabel, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: statusCellControlMargin))
        pictureWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureHeightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
    }
    
    
    //懒加载控件
    private lazy var forwordLabel: UILabel = {
        
        let label = UILabel(color: UIColor.darkGrayColor(), fontSize: 14)
        
        label.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * statusCellControlMargin
        
        label.numberOfLines = 0
        
        return label
    }()
    
    private lazy var backButton: UIButton = {
        
        let btn = UIButton()
        
        btn.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        
        return btn
    }()
}
